
#include <stdio.h>
#include <arpa/inet.h>

int main(int argc,char *argv[])
{
    char *addr1 = "1.2.3.4";
    char *addr2 = "1.2.3.333";

    unsigned long conv_addr = inet_addr(addr1);
    printf("网络序数字IP地址： %#lx \n", conv_addr);

    conv_addr = inet_addr(addr2);
    if(conv_addr == INADDR_NONE) {
        printf("转换失败\n");
    } else {
        printf("网络序数字IP地址： %#lx \n", conv_addr);
    }
    return 0;
}
